// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Security
{
	public sealed class SecurityInvalidateTokenRequestParameters : RequestParameters<SecurityInvalidateTokenRequestParameters>
	{
	}

	public sealed partial class SecurityInvalidateTokenRequest : PlainRequestBase<SecurityInvalidateTokenRequestParameters>
	{
		internal override ApiUrls ApiUrls => ApiUrlsLookups.SecurityInvalidateToken;
		protected override HttpMethod HttpMethod => HttpMethod.DELETE;
		protected override bool SupportsBody => true;
		[JsonInclude]
		[JsonPropertyName("token")]
		public string? Token { get; set; }

		[JsonInclude]
		[JsonPropertyName("refresh_token")]
		public string? RefreshToken { get; set; }

		[JsonInclude]
		[JsonPropertyName("realm_name")]
		public Elastic.Clients.Elasticsearch.Name? RealmName { get; set; }

		[JsonInclude]
		[JsonPropertyName("username")]
		public Elastic.Clients.Elasticsearch.Username? Username { get; set; }
	}

	public sealed partial class SecurityInvalidateTokenRequestDescriptor : RequestDescriptorBase<SecurityInvalidateTokenRequestDescriptor, SecurityInvalidateTokenRequestParameters>
	{
		internal SecurityInvalidateTokenRequestDescriptor(Action<SecurityInvalidateTokenRequestDescriptor> configure) => configure.Invoke(this);
		public SecurityInvalidateTokenRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.SecurityInvalidateToken;
		protected override HttpMethod HttpMethod => HttpMethod.DELETE;
		protected override bool SupportsBody => true;
		private Elastic.Clients.Elasticsearch.Name? RealmNameValue { get; set; }

		private string? RefreshTokenValue { get; set; }

		private string? TokenValue { get; set; }

		private Elastic.Clients.Elasticsearch.Username? UsernameValue { get; set; }

		public SecurityInvalidateTokenRequestDescriptor RealmName(Elastic.Clients.Elasticsearch.Name? realmName)
		{
			RealmNameValue = realmName;
			return Self;
		}

		public SecurityInvalidateTokenRequestDescriptor RefreshToken(string? refreshToken)
		{
			RefreshTokenValue = refreshToken;
			return Self;
		}

		public SecurityInvalidateTokenRequestDescriptor Token(string? token)
		{
			TokenValue = token;
			return Self;
		}

		public SecurityInvalidateTokenRequestDescriptor Username(Elastic.Clients.Elasticsearch.Username? username)
		{
			UsernameValue = username;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (RealmNameValue is not null)
			{
				writer.WritePropertyName("realm_name");
				JsonSerializer.Serialize(writer, RealmNameValue, options);
			}

			if (!string.IsNullOrEmpty(RefreshTokenValue))
			{
				writer.WritePropertyName("refresh_token");
				writer.WriteStringValue(RefreshTokenValue);
			}

			if (!string.IsNullOrEmpty(TokenValue))
			{
				writer.WritePropertyName("token");
				writer.WriteStringValue(TokenValue);
			}

			if (UsernameValue is not null)
			{
				writer.WritePropertyName("username");
				JsonSerializer.Serialize(writer, UsernameValue, options);
			}

			writer.WriteEndObject();
		}
	}
}